<template>
    <div></div>
</template>

<script>
import Oidc from "oidc-client";
import { oidcSettings} from '@/api/oidc'

export default {
  props: {},
  data() {
    return {}
  },
  watch: {
    $route: {
      handler: function(route) {
        this.redirect = route.query && route.query.redirect
      },
      immediate: true
    }
  },
  components: {},
  methods: {},
  created() {
    let userManager = new Oidc.UserManager(oidcSettings)
    userManager.signinRedirectCallback().then(() => {
      this.$store.dispatch('user/login').then(() => { 
        this.$router.push({ path: this.redirect || '/' })
      }).catch(() => {
        this.$router.push({ path: '/login' })
      })
    })
    .catch(function(e) {
       console.error("CallBack 错误信息" + e)
    })
  }
}
</script>